<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var i = 0;
    function foo(){
        i++;
        console.log(i);
    }
    foo();
    foo();
    foo();
    foo();
</script>
</body>
</html>